import 'package:basic_common/app_theme.dart';
import 'package:basic_common/common_exports.dart';
import 'package:basic_widgets/button_widget.dart';
import 'package:basic_widgets/image_widget.dart';
import 'package:basic_widgets/input_widget.dart';
import 'package:flutter/material.dart';

import '../realname_controller.dart';


/// 医生认证
class AuthenView extends GetView<RealNameController> {
  const AuthenView({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: AppTheme.appBgColor,
      child: Column(
        children: [
          Container(
            color: Colors.white,
            padding: EdgeInsets.only(bottom: ScreenHelper.height(10)),
            child: Column(
              children: [
                _buildTitle(
                    subTitle:
                        "带有执业医院名称的是执业证书吗，请上传执业证书的所有内容页面(含变更页)的彩色原证件照片，不得遮挡、缺损",
                    title: '请上传您的执业证书'),
                Obx(() => seleImageWidget(
                    defaultImg: 'assets/register/img_zhiye_home.png',
                    webImg: controller.imgPathPrac1.value,
                    info: '点击上传主页',
                    onTap: () {
                      controller.showSelectImg(type: 3);
                    })),
                Obx(() => seleImageWidget(
                    defaultImg: 'assets/register/img_zhiye_info.png',
                    info: '点击上传个人信息\n页及变更页',
                    webImg: controller.imgPathPrac2.value,
                    onTap: () {
                      controller.showSelectImg(type: 4);
                    })),
              ],
            ),
          ),
          Container(
            color: Colors.white,
            margin: EdgeInsets.only(top: ScreenHelper.height(10)),
            padding: EdgeInsets.only(bottom: ScreenHelper.height(10)),
            child: Column(
              children: [
                _buildTitle(
                    subTitle: "需原件彩色照片，包含姓名，职称等信息的签发信息页，无遮挡、缺损",
                    title: '请上传您的职称证书'),
                Obx(() => seleImageWidget(
                    defaultImg: 'assets/register/img_zhicheng_home.png',
                    webImg: controller.imgPathTitle1.value,
                    info: '点击上传主页',
                    onTap: () {
                      controller.showSelectImg(type: 5);
                    })),
                Obx(() => seleImageWidget(
                    defaultImg: 'assets/register/img_zhicheng_info.png',
                    webImg: controller.imgPathTitle2.value,
                    info: '点击上传个人信息\n页及变更页',
                    onTap: () {
                      controller.showSelectImg(type: 6);
                    })),
              ],
            ),
          ),
          Container(
            color: Colors.white,
            margin: EdgeInsets.only(top: ScreenHelper.height(10)),
            padding: EdgeInsets.only(bottom: ScreenHelper.height(10)),
            child: Column(
              children: [
                _buildTitle(
                    subTitle: "您所在医院的工牌，内容清晰，不得有遮挡缺损", title: '请上传您的工作胸牌'),
                Obx(() => seleImageWidget(
                    defaultImg: 'assets/register/img_xiongpai.png',
                    webImg: controller.imgPathXp.value,
                    info: '点击上传胸牌',
                    onTap: () {
                      controller.showSelectImg(type: 7);
                    })),
              ],
            ),
          ),
          inputAreaBox(
              hint: '请描述您的专业领域、擅长疾病,如：擅长高血压、冠心病等疾病的诊断和治疗；擅长CT诊断，尤其对心血管疾病的影像诊断',
              title: '擅长领域',
              textControlller: controller.fieldController),
          inputAreaBox(
              title: '个人简介',
              hint:
                  '填写要求:1.简介内容:从业年限，毕业学校，进修经历，学术、科研成果，所获奖项，社会任职等2、不包含敏感词汇，黄赌毒、反党、不文明用语3、不虚假，不夸大',
              textControlller: controller.personalController),
          _bottomWidget()
        ],
      ),
    );
  }

// 标题
  Widget _buildTitle({required String title, required String subTitle}) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        buildInputInfoItem(arrowChild: SizedBox.shrink(), attrName: title),
        Padding(
          padding: EdgeInsets.symmetric(horizontal: ScreenHelper.width(15)),
          child: Text(
            subTitle,
            style: TextStyle(
                color: AppTheme.weakTextColor, fontSize: ScreenHelper.sp(12)),
          ),
        )
      ],
    );
  }

  /// 选择项
  Widget seleImageWidget(
      {required String defaultImg,
      required String webImg,
      required String info,
      required void Function()? onTap}) {
    return Container(
      margin: EdgeInsets.only(top: ScreenHelper.height(10)),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: [
          Stack(
            alignment: Alignment.bottomCenter,
            children: [
              Container(
                width: ScreenHelper.width(168),
                height: ScreenHelper.height(105),
                decoration: BoxDecoration(
                    image: DecorationImage(
                        fit: BoxFit.fill, image: AssetImage(defaultImg))),
              ),
              Container(
                width: ScreenHelper.width(168),
                height: ScreenHelper.height(30),
                color: AppTheme.hintTextColor,
                alignment: Alignment.center,
                child: Text(
                  "示意图",
                  style: TextStyle(
                      color: Colors.white, fontSize: ScreenHelper.sp(13)),
                ),
              )
            ],
          ),
          GestureDetector(
            onTap: onTap,
            child: Container(
              width: ScreenHelper.width(168),
              height: ScreenHelper.height(105),
              decoration: const BoxDecoration(color: AppTheme.appBgColor),
              child: webImg.isEmpty
                  ? Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Image.asset(
                          "assets/register/icon_camera.png",
                          width: ScreenHelper.width(30),
                        ),
                        SizedBox(
                          height: ScreenHelper.height(10),
                        ),
                        Text(
                          info,
                          textAlign: TextAlign.center,
                          style: TextStyle(
                              color: AppTheme.dartTextColor,
                              fontSize: ScreenHelper.sp(13)),
                        )
                      ],
                    )
                  :netWorkImgBox(netPath: webImg)
                  
                  //  Image.network(
                  //     webImg,
                  //     fit: BoxFit.cover,
                  //     height: ScreenHelper.height(110),
                  //   ),
                    
            ),
          )
        ],
      ),
    );
  }


  Widget _bottomWidget() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: ScreenHelper.width(30)),
      alignment: Alignment.centerLeft,
      margin: EdgeInsets.only(bottom: ScreenHelper.height(30)),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // Text(
          //   "请完成医生信息相关认证，否则将无法使用医生端相关功能",
          //   style: TextStyle(
          //       color: AppTheme.dartWeakTextColor,
          //       fontSize: ScreenHelper.sp(12)),
          // ),
          SizedBox(
            height: ScreenHelper.height(15),
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            mainAxisSize: MainAxisSize.min,
            children: [
              roundBtn(
                  text: '上一步',
                  borderColor: AppTheme.hintTextColor,
                  bgColor: Colors.white,
                  width: ScreenHelper.width(115),
                  onTap: () {
                  controller.preStep();
                  }),
              SizedBox(
                width: ScreenHelper.width(10),
              ),
              roundBtn(
                  text: '提交资质认证',
                  isEnable: true,
                  borderColor: AppTheme.primyColor,
                  bgColor: AppTheme.primyColor,
                  textColor: Colors.white,
                  
                  width: ScreenHelper.width(170),
                  onTap: () {
                    controller.addDrAuthInfo();

                    // Get.toNamed(AppRoutes.datareview);
                  }),
            ],
          )
        ],
      ),
    );
  }
}
